package com.example.activity;

import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;

import androidx.annotation.Nullable;

import com.example.studyapplication.R;
import com.example.util.UIHelper;

public class DialogActivity extends Activity {

    public static void startActivity(Context mContext){

        mContext.startActivity(new Intent(mContext, DialogActivity.class));

    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dialog);
    }


    public void showDialog(View view){
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        LayoutInflater inflater = LayoutInflater.from(this);
        View v = inflater.inflate(R.layout.dialog_custom, null);

        builder.setView(v);

        Dialog dialog = builder.create();
        dialog.show();
        //xml内设置宽高无效
        dialog.getWindow().setLayout(ActionBar.LayoutParams.MATCH_PARENT, UIHelper.dipToPx(this, 200));
        dialog.getWindow().setGravity(Gravity.BOTTOM);


    }
}
